package indi.lqzhi.basic.tools.socket.message.impl;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import indi.lqzhi.basic.tools.socket.message.IMessage;


public class StrMessage implements IMessage {

    private String message;

    private Charset charset;

    public StrMessage() {
        this.message = "";
        charset = StandardCharsets.US_ASCII;
    }

    public StrMessage(String message) {
        this.message = message;
        charset = StandardCharsets.US_ASCII;
    }

    public StrMessage(String message, Charset charset) {
        this.message = message;
        this.charset = charset;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Charset getCharset() {
        return charset;
    }

    public void setCharset(Charset charset) {
        this.charset = charset;
    }

    @Override
    public ByteBuffer getByteBuffer() {
        return ByteBuffer.wrap(message.getBytes(charset));
    }
}
